package com.ceba.test.modules.filemanage.logicService;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ceba.base.constants.FileClassConstants;
import com.ceba.base.enums.PdfOResultEnum;
import com.ceba.base.enums.SealTypeEnum;
import com.ceba.base.helper.LoggerHelper;
import com.ceba.base.sign.enums.ErrSign;
import com.ceba.base.utils.IDSFileUtils;
import com.ceba.base.utils.PDFUtils;
import com.ceba.base.utils.ToPdfUtils;
import com.ceba.base.web.response.IResult;
import com.ceba.cebautils.DateUtil;
import com.ceba.cebautils.StringUtil;
import com.ceba.test.base.config.LogicPathUtil;
import com.ceba.test.base.constants.CustomStampConstants;
import com.ceba.test.base.entity.SignPrintPDF;
import com.ceba.test.base.enums.EditionTypeEnum;
import com.ceba.test.base.utils.LogicCebaFileManageUtil;
import com.ceba.test.modules.admin.entity.GStamp;
import com.ceba.test.modules.admin.helper.GStampHelper;
import com.ceba.test.modules.log.helper.OpLogHelper;
import com.ceba.test.modules.sign.helper.SignInServerHelper;
import com.ceba.test.modules.statistic.entity.ReportSign;
import com.ceba.test.modules.storage.logicService.StorageFileCacheManage;
import com.ceba.test.modules.usermanage.entity.GSignatureMemory;
import com.ceba.test.modules.usermanage.service.GSignatureMemoryService;
import org.apache.commons.lang.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;
import com.ceba.test.base.configs.CebaConfig;
import com.ceba.test.base.helper.SystemHelper;
import com.ceba.test.base.language.ResourceUtils;
import com.ceba.test.modules.admin.entity.TemplateWord;
import com.ceba.test.modules.admin.service.StampService;
import com.ceba.test.modules.admin.service.TemplateWordService;
import com.ceba.test.modules.email.entity.MsgEmailSet;
import com.ceba.test.modules.email.logicService.EmailLogicService;
import com.ceba.test.modules.filemanage.dto.VFileObject;
import com.ceba.test.modules.filemanage.dto.WebSignParam;
import com.ceba.test.modules.filemanage.entity.GFile;
import com.ceba.test.modules.filemanage.entity.GFileRelaction;
import com.ceba.test.modules.filemanage.entity.GFolder;
import com.ceba.test.modules.filemanage.entity.MergeFile;
import com.ceba.test.modules.filemanage.entity.MessageEntity;
import com.ceba.test.modules.filemanage.service.FileManagerService;
import com.ceba.test.modules.filemanage.service.GFileService;
import com.ceba.test.modules.sign.helper.SignHelper;
import com.ceba.test.modules.sign.service.SignService;

import abc.ID;
import configs.context.SpringBeans;

public class FileManageLogicService {
    static Logger logger = LoggerFactory.getLogger(FileManageLogicService.class);

    private EmailLogicService emailLogicService = SpringBeans.getEmailLogicService("emailLogicService");

    private StampService stampService;
    private FileManagerService fileManagerService;
    private GFileService gFileService;

    private TemplateWordService templateWordService;

    private GSignatureMemoryService gSignatureMemoryService;


    /**
     * 根据ID获取文件物理地址,ID可能是报告ID或关联文件ID，文件ID
     *
     * @return
     */
    public GFile getFilePath(String id) {
        GFile file = fileManagerService.getFilePath(id);
        return file;
    }

    /**
     * 获取一个文件的datatable文件，同时他多出来一个关联文件名g_file_relaction.FILE_NAME AS
     * RELATION_FILE_NAME
     *
     * @param id
     * @return
     */

    public List<VFileObject> getFileInfosById(String id) {
        return fileManagerService.getFileInfosById(id);
    }


    /**
     * 获取目录的子文件与子目录（当前目录的）
     *
     * @param pathOrId 目录的路径或目录ID
     * @return
     * @throws Exception
     */
    public List<VFileObject> getFolder(String pathOrId) {
        return fileManagerService.getFolder(pathOrId);
    }


    /**
     * 获取文件信息json
     *
     * @param path
     * @param action 读取数据的动作指令
     * @return
     * @throws Exception
     */
    public String getFolder(String path, String action) {
        return fileManagerService.getFolder(path, action);
    }


    /**
     * 获取某一个文件夹关联的拓展目录
     *
     * @param path
     * @param json 原文件夹的目录结构
     * @return
     * @throws Exception
     */
    public JSONObject getRelationFolder(String path, JSONObject json) {
        return fileManagerService.getRelationFolder(path, json);
    }


    /**
     * 查询，全文和目录检索
     *
     * @param path
     * @param key  查询关键字
     * @return
     * @throws Exception
     */
    public String getFullTextSearchFolder(String path, String key) {
        return fileManagerService.getFullTextSearchFolder(path, key);
    }


    /**
     * 根据ID获取文件或目录的信息
     *
     * @param id
     * @return
     * @
     */
    public VFileObject getFileInfo(String id, String path) {
        return fileManagerService.getFileInfo(id, path);
    }

    /**
     * 获取一个FM目录下的所有目录结构
     *
     * @param fmPathOrId 目录路径或目录Id
     * @param key        查询的关键字
     * @return
     */
    public List<VFileObject> getFMFoldersList(String fmPathOrId, String key) {

        return fileManagerService.getFMFoldersList(fmPathOrId, key);
    }

    /**
     * 根据传过来的JSON获取所有的文件
     *
     * @param filesJson 文件json,包含文件Id或文件包Id
     * @return 所有文件的datatable
     */
    public List<VFileObject> getFMFilesByJson(String filesJson) {
        return fileManagerService.getFMFilesByJson(filesJson);
    }

    /**
     * 删除一个文件夹里面所有的内容
     *
     * @param fmPath 删除目录
     * @return
     * @
     */
    public Boolean deleteFolder(String fmPath) {
        return fileManagerService.deleteFolder(fmPath);
    }


    /**
     * 删除一个Fm关联文件
     *
     * @param relationId 删除目录
     * @return
     * @
     */
    public Boolean deleteFmFile(String relationId) {

        return fileManagerService.deleteFmFile(relationId);
    }


    /**
     * 删除一组文件，文件也可以是文件夹
     *
     * @param filesJson 文件json
     * @return
     * @
     */
    public Boolean deleteFiles(String filesJson) {
        return fileManagerService.deleteFiles(filesJson);
    }


    /**
     * 删除物理路径文件
     *
     * @param fileId 各种关联文件ID；
     * @return
     */
    public Boolean deletePhysicalFile(String fileId) {

        return fileManagerService.deletePhysicalFile(fileId);
    }


    /**
     * 文件夹是否存在,要特定用户
     *
     * @param path 目录路径
     * @return
     * @
     */
    public boolean existDirByUser(String path, String loginUserId) {
        return fileManagerService.existDirByUser(path, loginUserId);
    }

    /**
     * 文件夹下面是否存在子文件或者子文件夹
     *
     * @param id
     * @param path
     * @return
     * @
     */
    public boolean existChild(String id, String path, String loginUserId) {
        return fileManagerService.existChild(id, path, loginUserId);
    }

    /**
     * 获取复制到目录结构
     *
     * @param path
     * @return
     * @
     */

    public String getCopyFolderList(String path) {
        return fileManagerService.getCopyFolderList(path);
    }


    /**
     * 给当前目录加一个当日目录
     *
     * @param path 目录路径
     * @return
     * @
     */
    public boolean addDateDir(String path, String loginUserId) {
        return fileManagerService.addDateDir(path, loginUserId);
    }


    /**
     * 有一些默认的文件夹是添加报告目录中
     *
     * @param parentPath 父级目录路径
     * @return
     * @
     */
    public Boolean addDefalutRelationToReport(String parentPath, String loginUserId) {
        return fileManagerService.addDefalutRelationToReport(parentPath, loginUserId);
    }

    /**
     * 获取一个报告下面的所有PDF文件，主要是作为正式报告
     *
     * @return
     * @
     */
    public String getReleaseReportListJson(String reportId, String loginUserId) {
        return fileManagerService.getReleaseReportListJson(reportId, loginUserId);
    }


    /**
     * 在FM中发送邮件
     *
     * @param filesJson 要发送到文件
     * @param mailTo    发给对象
     * @param title     标题
     * @param context   内容
     * @return
     */
    public String sendEMailInFM(String filesJson, String mailTo, String title, String context, String loginUserId) {
        MsgEmailSet msgMailSet = emailLogicService.getMsgEmailSetById("6");
        List<VFileObject> vfs = fileManagerService.getFMFilesByJson(filesJson);
        return emailLogicService.sendEMailInFM(filesJson, mailTo, title, context, msgMailSet, loginUserId, vfs);
    }


    /**
     * 对选中的文件或文件夹签名进行签名
     *
     * @return
     */
    public IResult signFileOrDir(WebSignParam webSignParam) {
        IResult allResult = new IResult(true);
        //返回结果的集合
        List<MessageEntity> msgList = new ArrayList<MessageEntity>();
        int limitFile = 20;
        try {
            limitFile = Integer.parseInt(CebaConfig.SIGN_FILE_MAX);
        } catch (Exception e) {
            LoggerHelper.error(logger, e, "");
            limitFile = 20;
        }
        try {
            String filesJson = webSignParam.getFileJson();
            List<VFileObject> vfs = getFMFilesByJson(filesJson);
            if (vfs != null && vfs.size() > 0) {
                int iFiles = vfs.size();
                if (!SystemHelper.getBatchSign()) {
                    if (iFiles > 1) {
                        allResult.setResult(false);
                        allResult.setMessage("<div style='text-align:center; '>" + ResourceUtils.getMessage("MODULES_BATCH_SIGNATURE_ONLY_APPLICABLE_ONE") + "</div>" + "<div>" + ResourceUtils.getMessage("MODULES_BATCH_SIGNATURE_ONLY_APPLICABLE_TWO") + "</div>");
                        return allResult;
                    }
                }

                //zr证书过期
                if ("over".equals(signService.getValideDayOfLicense())) {
                    allResult.setResult(false);
                    allResult.setMessage(ResourceUtils.getMessage("MODULES_DIGITAL_CERTIFICATE_EXPIRED_SIGNATURE_FUNCTION"));
                    return allResult;
                }
                if (iFiles > limitFile) {
                    allResult.setResult(false);
                    allResult.setMessage(ResourceUtils.getMessage("MODULES_NO_MORE_BATCH_DIGITAL") + limitFile + ResourceUtils.getMessage("MODULES_A_FILE_OPERATION_NEED_SIGN") + iFiles + ResourceUtils.getMessage("MODULES_A_FILE"));//超过签名最大数量
                    return allResult;
                }
                //需要签名才判断
                if (webSignParam.getSignStampIds() != null && webSignParam.getSignStampIds().size() > 0) {
                    String errM = SignHelper.getCheckAllowSignErr();
                    if (!StringUtil.isEmptyString(errM)) {
                        if (errM.equals(ResourceUtils.getMessage(ErrSign.ERR_8.getLanguageFlag()))) {
                            MessageEntity entity = new MessageEntity();
                            entity.setMssage(errM);
                            msgList.add(entity);
                            allResult.setResult(false);
                            allResult.setMessage(JSON.toJSONString(msgList));
                            allResult.set("isMoreSign", "false");
                            return allResult;
                        }
                        allResult.setResult(false);
                        allResult.setMessage(errM);
                        return allResult;
                    }
                }


                Boolean bKeep = webSignParam.isbKeepFile();//是否保留原文件

                int iNoSign = 0;
                for (VFileObject vf : vfs) {
                    IResult result = new IResult(true);
                    //控制签名时关键字没匹配上是否报错 true-不报错 false-报错
                    result.set("isNoErrorNotNoramlMatchKey", webSignParam.isNoErrorNotNoramlMatchKey() ? "true":"false");
                    signFMFile(vf, bKeep, webSignParam, result);
                    if (!result.getResult()) {
                        MessageEntity entity = new MessageEntity();
                        entity.setFileName(vf.getFileRelactionName());
                        if (result.getResultCode() == 4) {
                            //表示已签名文档
                            entity.setFileType("pdfsign");
                        } else {
                            entity.setFileType(vf.getExtName());
                        }
                        entity.setMssage(result.getMessage());
                        entity.setCode(result.getResultCode());
                        msgList.add(entity);
                        iNoSign++;
                    }
                }


                if (iNoSign > 0) {
                    //return "本次数字证书签名"+iFiles+"个文件，未签名成功"+iNoSign+"个，请检查未成功文件！</br>1、数字证书签名只支持word、pdf、png、jpg、gif、txt等格式；</br>2、文件已经数字证书签名；";//超过签名最大数量
                    allResult.setResult(false);
                    allResult.set("iNoSign", iNoSign);
                    //判断是否多签
                    if (vfs.size() > 1) {
                        allResult.set("isMoreSign", "true");
                    } else {
                        allResult.set("isMoreSign", "false");
                    }
                    allResult.setMessage(JSON.toJSONString(msgList));
                    return allResult;
                }

                return allResult;

            }
        } catch (Exception e) {
            LoggerHelper.error(logger, e, "");
        }
        allResult.setResult(false);
        allResult.setMessage(ResourceUtils.getMessage("MODULES_SELECTION_SIGNATURE_FILE_PLEASE_CHECK_WHETHER_CURRENT"));
        return allResult;

    }

    /**
     * 客户端签之前  插入其他章   以及封装签名章的参数到页面
     */
    public IResult initializeSignDada(WebSignParam webSignParam) {
        IResult allResult = new IResult(true);
        String pdfPath = "";        //返回结果的集合
        String fileName = "";
        String signFileId = ID.getGuid();
        String gstampId = ID.getGuid();
        String qrcodeFileId = ID.getGuid();
        List<MessageEntity> msgList = new ArrayList<MessageEntity>();
        Map<String, Object> map = new HashMap<String, Object>(); //用来封装签章参数
        List<GStamp> g_StampList = new ArrayList<GStamp>();
        List<SignPrintPDF> signatureArrays = new ArrayList<SignPrintPDF>();

        try {
            String filesJson = webSignParam.getFileJson();
            List<VFileObject> vfs = getFMFilesByJson(filesJson);
            if (vfs.size() > 1) {
                allResult.setResult(false);
                allResult.setMessage("<div style='text-align:center; '>" + ResourceUtils.getMessage("MODULES_BATCH_SIGNATURE_ONLY_APPLICABLE_ONE") + "</div>" + "<div>" + ResourceUtils.getMessage("MODULES_BATCH_SIGNATURE_ONLY_APPLICABLE_TWO") + "</div>");
                return allResult;
            }

            int iNoSign = 0;
            for (VFileObject vf : vfs) {
                IResult result = new IResult(true);
                //控制签名时关键字没匹配上是否报错 true-不报错 false-报错
                result.set("isNoErrorNotNoramlMatchKey", webSignParam.isNoErrorNotNoramlMatchKey() ? "true":"false");
                pdfPath = initializeSignFMFile(vf, webSignParam, result, signFileId, qrcodeFileId);//插入非数字签章返回的路径
                fileName = vf.getFileRelactionName();
                if (!result.getResult()) {
                    MessageEntity entity = new MessageEntity();
                    entity.setFileName(vf.getFileRelactionName());
                    if (result.getResultCode() == 4) {
                        //表示已签名文档
                        entity.setFileType("pdfsign");
                    } else {
                        entity.setFileType(vf.getExtName());
                    }
                    entity.setMssage(result.getMessage());
                    entity.setCode(result.getResultCode());
                    msgList.add(entity);
                    iNoSign++;
                }
                if (webSignParam.getSignStampIds() == null || webSignParam.getSignStampIds().size() < 1) {
                    String signHelper = FileClassConstants.TOPDF;
                    //根据绝对路径取相对路径
                    String storageId = StorageFileCacheManage.getSystemUseAddressId();
                    String upfilePath = LogicPathUtil.getVirtualPath(storageId, pdfPath);
                    Boolean bKeep = webSignParam.isbKeepFile();
                    String newFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ".pdf";
                    GFile gf = GFile.createGFile(signFileId, newFileName, "", ""
                            , pdfPath, signHelper, webSignParam.getUserId(),
                            StorageFileCacheManage.getSystemUseAddressId(), LogicPathUtil.getVirtualPath(StorageFileCacheManage.getSystemUseAddressId(), upfilePath));
                    if (fileManagerService.addFileRecordByDocumentText(gf)) {
                        updataRelationFileSign(vf.getFileRelactionId(), signFileId);
                        String fileRelationId = ID.getGuid();
                        if (addFileRelationRecord(fileRelationId, signFileId, newFileName,
                                vf.getFolderId(), FileClassConstants.SIGN, webSignParam.getUserId(), storageId)) {
                            if (!bKeep) {
                                deleteFmFile(vf.getFileRelactionId());
                            }
                        }
                    }
                }
            }


            //封装签章数据   以备前端客户端签名
            if (!StringUtil.isEmptyString(pdfPath)) {
                map.put("fileName", fileName);
                map.put("filePath", pdfPath);
                map.put("fileId", signFileId);
                map.put("files", webSignParam.getFileJson());
                map.put("qrcodeFileId", qrcodeFileId);
                //根据章Id 获取签章对象
                Map<String, Object> paramMap = new HashMap<>();
                if (webSignParam.getSignStampIds().size() > 0) {
                    if (!webSignParam.getSignStampIds().get(0).equals(CustomStampConstants.NO_SIGN)) {
                        paramMap.put("g_stempIds", webSignParam.getSignStampIds().get(0) + ",");
                        g_StampList = GStampHelper.getCustomStampsListByIds(paramMap);
                    } else {
                        GStamp gStamp = new GStamp();
                        gStamp.setId(gstampId);
                        gStamp.setStamp_x("0");
                        gStamp.setStamp_y("-100");
                        gStamp.setImgWidth("0");
                        gStamp.setImgHeight("0");
                        gStamp.setFilePath(LogicPathUtil.getBrowserPath(StorageFileCacheManage.getSystemUseAddressId(), gStamp.getFilePath()));
                        g_StampList.add(gStamp);

                    }
                }

                map.put("g_StampList", g_StampList);
                //封装客户端签名所需参数
                for (GStamp gs : g_StampList) {
                    //判断签章是拖拽定位  还是关键字  如果是关键字  转换成定位
                    if (!webSignParam.getSignStampIds().get(0).equals(CustomStampConstants.NO_SIGN)) {
                        if (gs.getSealType().equals(SealTypeEnum.KEYWORD_STAMP_FLAG.getType())) {
                            String tempPath = LogicPathUtil.getPhysicalTempDirPath(StorageFileCacheManage.getSystemUseAddressId()) + ID.getGuid() + ".pdf";
                            JSONArray arrs = PDFUtils.getArraysOfPagesByMatchName(tempPath, pdfPath, gs.getMatchName(), Float.parseFloat(gs.getImgWidth()), Float.parseFloat(gs.getImgHeight()));
                            if (arrs != null && arrs.length() > 0) {
                                JSONObject o = arrs.getJSONObject(0);
                                gs.setStampPage(o.getString("stampPage"));
                            } else {
                                if (!SystemHelper.noErrorNotNoramlMatchKey()) {
                                    //关键字匹配失败
                                    allResult.setResult(false);
                                    allResult.setMessage(ResourceUtils.getMessage("KEY_WORD_MATCH_FAIL"));
                                    return allResult;
                                }
                            }
                        }
                    }

                    SignPrintPDF signPrintPDF = new SignPrintPDF();
                    signPrintPDF.setId(gs.getId());
                    signPrintPDF.setImagePath(gs.getFilePath());
                    signPrintPDF.setFloatImgWidth(Float.parseFloat(gs.getImgWidth()));
                    signPrintPDF.setFloatImgHeight(Float.parseFloat(gs.getImgWidth()));
                    signPrintPDF.setPdf_x(gs.getStamp_x());
                    signPrintPDF.setPdf_y(gs.getStamp_y());
                    signPrintPDF.setPage(gs.getStampPage());
                    signPrintPDF.setMatchName(gs.getMatchName());
                    signPrintPDF.setCerNo("");

                    signatureArrays.add(signPrintPDF);
                }
                map.put("signatureArrays", signatureArrays);
            }


            if (iNoSign > 0) {
                //return "本次数字证书签名"+iFiles+"个文件，未签名成功"+iNoSign+"个，请检查未成功文件！</br>1、数字证书签名只支持word、pdf、png、jpg、gif、txt等格式；</br>2、文件已经数字证书签名；";//超过签名最大数量
                allResult.setResult(false);
                allResult.set("iNoSign", iNoSign);
                //判断是否多签
                if (vfs.size() > 1) {
                    allResult.set("isMoreSign", "true");
                } else {
                    allResult.set("isMoreSign", "false");
                }
                allResult.setMessage(JSON.toJSONString(msgList));
            }

            //判断是否有数字章，如果没有则直接存数据库不进行后续操作
            allResult.set("pdfPath", pdfPath);
            allResult.set("dataMap", map);
            return allResult;

        } catch (Exception e) {
            LoggerHelper.error(logger, e, "");
        }
        allResult.setResult(false);
        allResult.setMessage(ResourceUtils.getMessage("MODULES_SELECTION_SIGNATURE_FILE_PLEASE_CHECK_WHETHER_CURRENT"));
        return allResult;
    }


    /**
     * 客户端签名成功后
     * 加记录添加到表中
     * 及 统计签名份数
     */
    public IResult insertClictData(WebSignParam webSignParam, String signFilePath, String qrcodeFileId) throws Exception {
        String staorageId = StorageFileCacheManage.getSystemUseAddressId();
        IResult result = new IResult(true);
        String filesJson = webSignParam.getFileJson();
        List<VFileObject> vfs = getFMFilesByJson(filesJson);
        Boolean bKeepFile = webSignParam.isbKeepFile();//是否保留原文件
        //由于客户端签不能批量签   所以这里只取第一个文件 （也只有一个文件）
        VFileObject vO = vfs.get(0);
        String fmFileId = vO.getFileRelactionId();
        String fileName = vO.getFileRelactionName();
        String signFileId = ID.getGuid();

        //获取统计的参数
        ReportSign parm = new ReportSign(1, webSignParam.getUserName(), EditionTypeEnum.BE.getType());

        String signHelper = FileClassConstants.SIGN;
        if (webSignParam.getSignStampIds() == null || (webSignParam.getSignStampIds() != null && webSignParam.getSignStampIds().size() == 0)) {
            signHelper = FileClassConstants.TOPDF;
        }

        if (!StringUtil.isEmptyString(signFilePath) && new File(signFilePath).exists()) {
            String newName = IDSFileUtils.getFileName(fileName, false) + ".pdf";
            GFile gf = GFile.createGFile(qrcodeFileId, fileName, "", vO.getTextContent()
                    , signFilePath, signHelper, webSignParam.getUserId(), StorageFileCacheManage.getSystemUseAddressId(), LogicPathUtil.getVirtualPath(StorageFileCacheManage.getSystemUseAddressId(), signFilePath));
            if (fileManagerService.addFileRecordByDocumentText(gf)) {
                updataRelationFileSign(fmFileId, signFileId);
                String fileRelationId = ID.getGuid();
                if (addFileRelationRecord(fileRelationId, qrcodeFileId, newName,
                        vO.getFolderId(), FileClassConstants.SIGN, webSignParam.getUserId(), staorageId)) {
                    if (!bKeepFile) {
                        deleteFmFile(fmFileId);
                    }
                }
            }
            parm.setFileId(qrcodeFileId);
            parm.setQrCodeFileId(qrcodeFileId);
            SignInServerHelper.afterSign(1, signFilePath, parm);
            //日志打印
            OpLogHelper.signOperationLogs(parm.getCreateUserName() + "于"
                    + DateUtil.getNowTime(DateUtil.YYYY_MM_DD_HH_MM_SS) + "对报告" + fileName + "进行签名 ");

        } else {
            result.setResult(false);
            result.setMessage(ResourceUtils.getMessage(PdfOResultEnum.PDF_EXCEPTIONS.getResourceName()));
            OpLogHelper.signOperationLogs(parm.getCreateUserName() + "于"
                    + DateUtil.getNowTime(DateUtil.YYYY_MM_DD_HH_MM_SS) + "对报告" + fileName + "签名签名失败");
        }
        return result;

    }


    /**
     * 在FM中签名一个文件夹里面的内容
     *
     * @param fmForderId 需要签名的FM中文件夹的Id
     * @param bKeepFile  是否保留原文件
     */
    public IResult signFMFolder(String fmForderId, Boolean bKeepFile, WebSignParam webSignParam) {
        int iSign = 0;
        IResult result = new IResult(true);
        try {
            //需要签名才判断
            if (webSignParam.getSignStampIds() != null && webSignParam.getSignStampIds().size() > 0) {
                String errM = SignHelper.getCheckAllowSignErr();
                if (!StringUtil.isEmptyString(errM)) {
                    result.setResult(false);
                    result.setMessage(errM);
                    return result;
                }
            }
            List<VFileObject> vfList = fileManagerService.getFMFilesListByFolderId(fmForderId, "");
            if (vfList != null && vfList.size() > 0) {
                for (VFileObject row : vfList) {
                    result = signFMFile(row.getId(), bKeepFile, webSignParam);
                    if (result.getResult()) {
                        iSign++;
                    }
                }
                result.set("count", iSign);
            }
        } catch (Exception e) {
            LoggerHelper.error(logger, e, "");
        }
        return result;
    }

    /**
     * 在FM中签名一个文件
     *
     * @param fmFileId  需要签名的FM中文件的Id
     * @param bKeepFile 是否保留原文件
     * @return
     */
    private IResult signFMFile(String fmFileId, Boolean bKeepFile, WebSignParam webSignParam) {
        IResult result = new IResult(true);
        //控制签名时关键字没匹配上是否报错 true-不报错 false-报错
        result.set("isNoErrorNotNoramlMatchKey", webSignParam.isNoErrorNotNoramlMatchKey() ? "true":"false");
        try {
            List<VFileObject> vOs = fileManagerService.getFileInfosById(fmFileId);
            if (vOs != null && vOs.size() > 0) {
                signFMFile(vOs.get(0), bKeepFile, webSignParam, result);
                return result;
            }
        } catch (Exception e) {
            LoggerHelper.error(logger, e, "");
        }
        result.setResult(false);
        result.setMessage(ResourceUtils.getMessage("SIGN_GENERATOR_ERROR"));
        return result;
    }


    /**
     * 客户端签 只插入非数字签名章
     */
    private String initializeSignFMFile(VFileObject vO, WebSignParam webSignParam, IResult result, String signFileId, String qrcodeFileId) {
        try {
            String staorageId = StorageFileCacheManage.getSystemUseAddressId();
            if (vO != null) {
				/*String path = vO.getFilePath();*/
                String storageId = StorageFileCacheManage.getSystemUseAddressId();
                String path = LogicPathUtil.getAbsolutelyPath(storageId, vO.getVirtualPath());
                String tempPath = LogicPathUtil.getPhysicalTempDirPath(staorageId) + ID.getGuid() + ".pdf";
                //上传文档能否转PDF判断
                if (ToPdfUtils.fileToPdf(path, tempPath)) {
                    if (!IDSFileUtils.checkFileExits(tempPath)) {
                        tempPath = path;
                    }

                    String fileName = vO.getFileRelactionName();
                    webSignParam.setFileName(fileName);
                    webSignParam.setFileId(signFileId);
                    SignHelper.signFileInFM(tempPath, webSignParam, result, qrcodeFileId);
                } else {
                    File file = new File(path);
                    result.setResult(false);
                    if (file.exists()) {
                        result.setMessage(ResourceUtils.getMessage(PdfOResultEnum.PDF_EXCEPTIONS.getResourceName()));
                    } else {
                        result.setMessage(ResourceUtils.getMessage("SYSTEM_FILE_NOT_EXIST"));
                    }
                }
                return result.getString("filePath");
            }
        } catch (Exception e) {
            LoggerHelper.error(logger, e, "");
        }

        return null;

    }


    /**
     * 在FM中签名一个文件
     *
     * @param bKeepFile 是否保留原文件
     * @return
     */
    private void signFMFile(VFileObject vO, Boolean bKeepFile, WebSignParam webSignParam, IResult result) {
        try {
            String staorageId = StorageFileCacheManage.getSystemUseAddressId();
            if (vO != null) {
                String fmFileId = vO.getFileRelactionId();
                String qrcodeFileId = ID.getGuid();
                //物理路径
                String path = vO.getFilePath();
                String storageId = StorageFileCacheManage.getSystemUseAddressId();
                //相对路径
                String virtualPath = vO.getVirtualPath();
                //根据相对路径取绝对路径
                String filePath = LogicPathUtil.getFilePathByVirtualPath(storageId, virtualPath);
                String tempPath = LogicPathUtil.getPhysicalTempDirPath(staorageId) + ID.getGuid() + ".pdf";

                //上传文档能否转PDF判断
                if (ToPdfUtils.fileToPdf(filePath, tempPath)) {
                    if (!IDSFileUtils.checkFileExits(tempPath)) {
                        tempPath = path;
                    }
                    String signFileId = qrcodeFileId; //fileId和二维码id使用同一个

                    String fileName = vO.getFileRelactionName();
                    webSignParam.setFileName(fileName);
                    webSignParam.setFileId(signFileId);
                    SignHelper.signFileInFM(tempPath, webSignParam, result, qrcodeFileId);
                    String signHelper = FileClassConstants.SIGN;
                    if (webSignParam.getSignStampIds() == null || (webSignParam.getSignStampIds() != null && webSignParam.getSignStampIds().size() == 0)) {
                        signHelper = FileClassConstants.TOPDF;
                    }
                    if (result.getResult()) {
                        String signFilePath = result.getString("filePath");
                        if (!StringUtil.isEmptyString(signFilePath)) {
                            String newName = IDSFileUtils.getFileName(fileName, false) + ".pdf";
                            GFile gf = GFile.createGFile(qrcodeFileId, fileName, "", vO.getTextContent()
                                    , signFilePath, signHelper, webSignParam.getUserId(), StorageFileCacheManage.getSystemUseAddressId(), LogicPathUtil.getVirtualPath(StorageFileCacheManage.getSystemUseAddressId(), signFilePath));
                            if (fileManagerService.addFileRecordByDocumentText(gf)) {
                                updataRelationFileSign(fmFileId, signFileId);
                                String fileRelationId = ID.getGuid();
                                if (addFileRelationRecord(fileRelationId, qrcodeFileId, newName,
                                        vO.getFolderId(), FileClassConstants.SIGN, webSignParam.getUserId(), staorageId)) {
                                    if (!bKeepFile) {
                                        deleteFmFile(fmFileId);
                                    }
                                    return;
                                }
                            }
                        }
                    } else {
                        return;
                    }
                } else {
                    result.setResult(false);
                    File file = new File(path);
                    if (file.isFile() && file.exists()) {
                        result.setMessage(ResourceUtils.getMessage(PdfOResultEnum.SIGN_ONLY_FOR_PDF.getResourceName()));
                    } else {
                        //文件不存在
                        result.setMessage(ResourceUtils.getMessage("SYSTEM_FILE_NOT_EXIST"));
                    }
                }
            }
        } catch (Exception e) {
            LoggerHelper.error(logger, e, "");
        }

    }


    /**
     * @param reportId
     * @return
     */
    public JSONArray getFileRoleListJson(String reportId) {
        return fileManagerService.getFileRoleListJson(reportId);
    }

    /**
     * 取得报告的原始文件
     *
     * @param reportid
     * @return
     */
    public JSONArray reportOriginalFile(String reportid) {
        return fileManagerService.reportOriginalFile(reportid);
    }

    /*
     * 根据用户id和目录id获取目录是否创建
     */
    public long getCountOfFolderById(String userId, String foldId) {
        return fileManagerService.getCountOfFolderById(userId, foldId);
    }

    /**
     * 目录更名
     *
     * @param oldPath       原目录路径
     * @param newFolderName 新目录名
     * @param classString   分类
     * @return
     * @throws Exception
     */
    public boolean updateFolderName(String id, String oldPath, String newFolderName, String classString, String loginUserId) {
        return fileManagerService.updateFolderName(id, oldPath, newFolderName, classString, loginUserId);
    }


    /**
     * 添加一个签名目录
     *
     * @return
     * @
     */
    public boolean addSignDir(String loginUserId) {
        return fileManagerService.addSignDir(loginUserId);
    }

    /*
     * 根据用户id和文件关联id，获取文件
     */
    public long getCountOfGFileRelactionById(String userId, String fileRelactionId) {
        return fileManagerService.getCountOfGFileRelactionById(userId, fileRelactionId);
    }


    /**
     * FM文件更名
     *
     * @param id
     * @param oldPath
     * @param newName
     * @return
     */
    public boolean updateFmFileName(String id, String oldPath, String newName, String loginUserId) {
        return fileManagerService.updateFmFileName(id, oldPath, newName, loginUserId);
    }

    /*
     * 根据目录id获取文件路径
     */
    public String getPathOfFolderById(String userId, String id) {
        return fileManagerService.getPathOfFolderById(userId, id);
    }

    /**
     * 当前文件夹是否有权限操作
     *
     * @param pathOrID 路径或ID
     * @return
     */
    public Boolean isMyFolder(String pathOrID, String loginUserId) {
        return fileManagerService.isMyFolder(pathOrID, loginUserId);
    }

    /*
     * 根据文件名+目录路径获取文件对象
     */
    public GFileRelaction getGFRelactionByFolderPathAndFileName(String fileName, String virtualPath) {
        return fileManagerService.getGFRelactionByFolderPathAndFileName(fileName, virtualPath);
    }

    /*
     * 根据条件更新g_file
     */
    public boolean updateGFileByQuery(String updates, String condition) {
        return fileManagerService.updateGFileByQuery(updates, condition);
    }


    /**
     * 把一个文件添加到g_file中
     *
     * @return
     * @throws Exception
     */
    public Boolean addFileRecord(GFile gf) {
        return fileManagerService.addFileRecord(gf);
    }

    /**
     * 把一个压缩包解压,并转存到文件管理器中（转数据库）
     *
     * @param zipPath          zip包物理路径
     * @param fmRootFolderPath filemanage导入根目录虚拟路径
     * @return
     * @throws Exception
     */

    public Boolean unZipToFileManager(String zipPath, String fmRootFolderPath, String loginUserId, String storageId) {
        try {
            String toFolderPath = LogicPathUtil.getFolderUserPath(storageId, loginUserId);
            String tempPath = LogicCebaFileManageUtil.unZipToTempFolder(zipPath, storageId);
            String verPath = LogicPathUtil.getVirtualPath(storageId, toFolderPath);
            String fmPath = tempPath.replace(LogicPathUtil.getPhysicalTempDirPath(storageId), fmRootFolderPath);
            return fileManagerService.unZipToFileManager(zipPath, fmRootFolderPath, loginUserId, toFolderPath, tempPath, storageId, verPath, fmPath);
        } catch (Exception e) {
            LoggerHelper.error(logger, e, "");
        }

        return false;
    }


    /*
     * 根据用户ID+虚拟路径名获取文件目录
     */
    public GFolder getGFolderByUserIdAndVirtualPath(String userId, String virtualPath) {
        return fileManagerService.getGFolderByUserIdAndVirtualPath(userId, virtualPath);
    }


    /**
     * 把一个文件添加到数据库中,并建立文件关联
     *
     * @param fileRelationId ID，如果为空，自动获取
     * @param fileId         文件ID，必须存在；
     * @param fileName       文件名
     * @param folderId       文件目录，必须存在；；
     * @return
     * @throws Exception
     */

    public Boolean addFileRelationRecord(String fileRelationId, String fileId, String fileName, String folderId, String flag, String loginUserId, String storageId) {
        return fileManagerService.addFileRelationRecord(fileRelationId, fileId, fileName, folderId, flag, loginUserId, storageId);
    }

    public boolean addGFileRelaction(GFileRelaction gfr) {
        if (null == gfr.getStorageAddressId() || gfr.getStorageAddressId().isEmpty()) {
            gfr.setStorageAddressId(StorageFileCacheManage.getSystemUseAddressId());
        }
        return gFileService.addGFileRelaction(gfr);
    }


    /**
     * 添加一个目录
     *
     * @return
     * @throws Exception
     */
    public boolean addFolder(GFolder gFolder) {
        return fileManagerService.addFolder(gFolder);
    }


    /**
     * 拷贝一组文件，文件也可以是文件夹
     *
     * @param filesJson  文件json
     * @param toFolderId 拷贝目录的ID
     * @return
     * @throws Exception
     */
    public Boolean copyFiles(String filesJson, String toFolderId, String loginUserId) {
        return fileManagerService.copyFiles(filesJson, toFolderId, loginUserId);
    }


    /**
     * 拷贝目录
     *
     * @param copyFolderId 要拷贝目录ID
     * @param toFolderId   目标目录的ID
     * @param name         拷贝目录名
     * @return
     * @throws Exception
     */
    public Boolean copyFolder(String copyFolderId, String toFolderId, String name, String loginUserId) {
        return fileManagerService.copyFolder(copyFolderId, toFolderId, name, loginUserId);
    }


    /**
     * 拷贝文件
     *
     * @param relactionFileId 要拷贝文件的关联ID
     * @param folderId        拷贝目录的ID
     * @param fileName        拷贝的文件名
     * @return
     * @throws Exception
     */
    public Boolean copyFile(String relactionFileId, String folderId, String fileName, String loginUserId) {
        return fileManagerService.copyFile(relactionFileId, folderId, fileName, loginUserId);
    }

    /**
     * 剪切一组文件，文件也可以是文件夹
     *
     * @param filesJson  文件json
     * @param toFolderId 拷贝目录的ID
     * @return
     * @throws Exception
     */
    public Boolean cutFiles(String filesJson, String toFolderId, String loginUserId) {
        return fileManagerService.cutFiles(filesJson, toFolderId, loginUserId);
    }


    /**
     * 剪切目录
     *
     * @param cutFolderId 要剪切目录ID
     * @param toFolderId  剪切目录的ID
     * @param folderName  变更的目录名
     * @return
     * @throws Exception
     */
    public Boolean cutFolder(String cutFolderId, String toFolderId, String folderName, String loginUserId) {
        return fileManagerService.cutFolder(cutFolderId, toFolderId, folderName, loginUserId);
    }


    /**
     * 剪切文件
     *
     * @param relactionFileId 要剪切文件的关联ID
     * @param folderId        剪切目录的ID
     * @param fileName        剪切的文件名
     * @return
     * @throws Exception
     */
    public Boolean cutFile(String relactionFileId, String folderId, String fileName, String loginUserId) {
        return fileManagerService.cutFile(relactionFileId, folderId, fileName, loginUserId);
    }

    /**
     * 文件转PDF
     *
     * @return
     * @throws Exception
     */
    public Boolean toPDF(String fileID, String folderID, String loginUserId) {
        String storageId = StorageFileCacheManage.getSystemUseAddressId();
        String outPath = LogicPathUtil.getPhysicalToPDFFolder(storageId) + ID.getGuid() + ".pdf";
        String verPath = LogicPathUtil.getVirtualPath(storageId, outPath);

        return fileManagerService.toPDF(fileID, folderID, loginUserId, storageId, outPath, verPath);
    }

    /**
     * 更新一个relation文件的相关的签名Id
     *
     * @param fileRelationId
     * @param signFileId     签名文件的g_file.ID
     * @return
     * @throws Exception
     */

    public Boolean updataRelationFileSign(String fileRelationId, String signFileId) {
        return fileManagerService.updataRelationFileSign(fileRelationId, signFileId);
    }

    /**
     * 把一个文件添加到数据库中insert语句,不写读取报告内容
     *
     * @return
     * @throws Exception
     */
    public Boolean addFileRecordNoDocumentText(GFile gf) {
        return fileManagerService.addFileRecordNoDocumentText(gf);
    }


    /**
     * 根据 g_file 表的id 取得 g_file_ralation id
     *
     * @param fileidArray
     * @return
     */
    public String getRelationFile(String[] fileidArray) {
        return fileManagerService.getRelationFile(fileidArray);
    }

    /**
     * 合并文件
     *
     * @param filePath 合并后的文件的目录
     * @param fileName 合并后的文件名称
     * @return JSON数据返回
     */
    public String mergeFile(String fileName, String filePath, MergeFile[] mergeFiles, String loginUserId) {

        String storageId = StorageFileCacheManage.getSystemUseAddressId();
        //1.取出合并的文件（文件路径）
        String savePath = LogicPathUtil.getFolderOfUser(storageId, loginUserId) + fileName + ".pdf";

        //获取该路径 的相对路径
        String verPath = LogicPathUtil.getVirtualPath(storageId, savePath);

        return fileManagerService.mergeFile(fileName, savePath, mergeFiles, loginUserId, storageId, verPath);
    }

    /**
     * 更加ID获取文件url地址,ID可能是报告ID或关联文件ID，文件ID
     *
     * @return
     * @
     */
    public String getFileUrlPath(String id) {
        return fileManagerService.getFileUrlPath(id);
    }

    /*
     * 根据条件获取目录字段值
     */
    public String getFolderFieldValueByFolderPath(String fieldName, String query) {
        return fileManagerService.getFolderFieldValueByFolderPath(fieldName, query);
    }


    /**
     * 把一个目录打包成Zip文件
     *
     * @param folderID 文件目录ID
     * @return
     * @throws Exception
     */
    public String getFolderZip(String folderID) {
        try {
            String storageId = StorageFileCacheManage.getSystemUseAddressId();
            String zipPath = LogicPathUtil.getPhysicalTempDirPath(storageId) + ID.getGuid();
            return LogicPathUtil.getVirtualPath(storageId, fileManagerService.getFolderZip(folderID, zipPath, null));
        } catch (Exception e) {
            LoggerHelper.error(logger, e, "");
        }
        return "";

    }

    /**
     * 下载一组选择的文件,包括文件夹
     *
     * @param jsonFiles  文件json
     * @param folderName 压缩包名，也是文件夹名
     * @return -1代表打包文件超过25M，
     * @throws Exception
     */
    public String getZipFiles(String jsonFiles, String folderName) {
        try {
            String zipPath = LogicPathUtil.getPhysicalTempDirPath(StorageFileCacheManage.getSystemUseAddressId()) + ID.getGuid() + "/" + folderName + ".zip";
            return LogicPathUtil.getVirtualPath(StorageFileCacheManage.getSystemUseAddressId(), fileManagerService.getZipFiles(jsonFiles, folderName, zipPath));
        } catch (Exception e) {
            LoggerHelper.error(logger, e, "");
        }
        return "";
    }

    /**
     * 验证文件是否能转换为PDF
     *
     * @param fileInfoMap
     * @return
     */
    public String validFileConversionPDF(Map<Integer, String> fileInfoMap) {
        String tempBaseFilePath = LogicPathUtil.getPhysicalTempFolder(StorageFileCacheManage.getSystemUseAddressId());
        return fileManagerService.validFileConversionPDF(fileInfoMap, tempBaseFilePath);
    }

    /**
     * 文件夹是否存在,要特定用户
     *
     * @param path 目录路径
     * @return
     * @
     */
    public boolean existDirByUser1(String path, String loginUserId) {
        return fileManagerService.existDirByUser(path, loginUserId);
    }


    /**
     * 拷贝目录
     *
     * @param copyFolderId 要拷贝目录ID
     * @param toFolderId   目标目录的ID
     * @param name         拷贝目录名
     * @return
     * @throws Exception
     */
    public Boolean copyFolder(String copyFolderId, String toFolderId, String name, String userId, String loginUserId) {
        return fileManagerService.copyFolder(copyFolderId, toFolderId, name, userId);
    }

    /**
     * 获取一个报告下面的所有PDF文件，主要是作为正式报告
     *
     * @return
     * @
     */
    public String getReleaseReportRoleListJson(String reportId, String loginUserId) {
        return fileManagerService.getReleaseReportRoleListJson(reportId, loginUserId);
    }

    /**
     * 通过路径寻找folderId
     *
     * @param path
     * @return
     */
    public String getFolderIdByPath(String path) throws Exception {
        return fileManagerService.getFolderIdByPath(path);
    }


    public String getFieldStringValue(String userId, String reportId) throws Exception {
        return fileManagerService.getFieldStringValue(userId, reportId);
    }

    /**
     * 每日定时清理临时文件
     *
     * @throws Exception
     */
    public void timeToEmptyTempFolder() {
        try {
            String d = CebaConfig.get("TIME_TO_CLEAR_TEMP_FILE");
            String td = DateUtil.getDayTime(DateUtil.YYYY_MM_DD_, 0);
            if (!td.equals(d)) {
                if (LogicCebaFileManageUtil.emptyTempFolder(StorageFileCacheManage.getSystemUseAddressId())) {
                    CebaConfig.set("TIME_TO_CLEAR_TEMP_FILE", td);
                }

            }
        } catch (Exception e) {
            LoggerHelper.error(logger, e, "");
        }

    }

    //GFileService 类

    /**
     * 添加纪录
     *
     * @param gFile
     * @return
     */
    public boolean addFile(GFile gFile) throws Exception {
        if (gFile.getStorageAddressId().isEmpty()) {
            gFile.setStorageAddressId(StorageFileCacheManage.getSystemUseAddressId());
        }
        return gFileService.addFile(gFile);
    }


    /**
     * 根据id获取
     *
     * @param fileId
     * @return
     */
    public GFile getGFileByFileId(String fileId) {
        return gFileService.getGFileByFileId(fileId);
    }

    /**
     * 删除
     *
     * @param invalidFileId
     * @return
     * @throws Exception
     */
    public boolean deleteFileByFileId(String invalidFileId) throws Exception {
        return gFileService.deleteFileByFileId(invalidFileId);
    }

    /*
     * 根据id获取关联文件
     */
    public GFileRelaction getGFileRelactionById(String gFileRelactionId) {
        return gFileService.getGFileRelactionById(gFileRelactionId);
    }


    /**
     * 删除不需要的缓存文件
     * 0--成功
     * 1--没有需要删除的缓存文件
     * 100--删除时出现异常
     * 其他情况，返回删除的个数
     *
     * @return
     */
    public String deleteTempUse() {
        return fileManagerService.deleteTempUse();
    }

    /**
     * @param id
     * @param fieldName 字段ID
     * @return
     */
    public String getFieldValue(String table, String id, String fieldName) throws Exception {
        return gFileService.getFieldValue(table, id, fieldName);
    }

    public String fileIdGetVirtualPath(String g_fileId) throws Exception {
        return gFileService.fileIdGetVirtualPath(g_fileId);
    }

    /**
     * @param fileId
     * @return
     */
    public GFileRelaction getFileRelactionById(String fileId) {
        return fileManagerService.getFileRelactionById(fileId);
    }

    /**
     * 判断签名文件是否合格
     *
     * @param relaction_id
     */
    public GFileRelaction isSignFile(String relaction_id) {
        return fileManagerService.isSignFile(relaction_id);
    }

    /**
     * 在一个目录中是否存在相同文件名，如果存在这把这个文件名更改，主要用于复制文件，添加FM记录
     *
     * @param fileName 文件名
     * @param folderId 目录ID
     * @return
     */
    public String getFileNameInFolder(String fileName, String folderId) {
        return fileManagerService.getFileNameInFolder(fileName, folderId);
    }

    /**
     * 获取pdf路径
     *
     * @return uploadBashFilePath
     */
    @SuppressWarnings({"rawtypes", "unchecked"})
    public Map<String, String> getPdfPath(String fileId, String isTemplates) {
        Map<String, String> resultMap = new HashMap();
        String fileName = null, filePath = null;
        TemplateWord tw = new TemplateWord();
        if (StringUtils.equals("false", isTemplates)) {
            VFileObject vf = fileManagerService.getFileIdFilePath(fileId);
            filePath = LogicPathUtil.getFilePathByTemplateVirtualPath(vf.getStorageAddressId(), vf.getVirtualPath());
            fileName = vf.getFileName();
        } else {
            if (StringUtils.isNotEmpty(fileId)) {
                tw = templateWordService.getTemplateIdFilePath(fileId);
                filePath = LogicPathUtil.getFilePathByTemplateVirtualPath(tw.getStorageAddressId(), tw.getWordVirtualPath());
            } else {
                tw = templateWordService.getTemplateFilePath();
                fileId = tw.getId();
                filePath = LogicPathUtil.getFilePathByTemplateVirtualPath(tw.getStorageAddressId(), tw.getWordVirtualPath());
            }
            fileName = tw.getWordName();
        }
        resultMap.put("fileName", fileName);
        resultMap.put("filePath", filePath);
        resultMap.put("fileId", fileId);
        return resultMap;
    }

    public boolean addGSignature(GSignatureMemory gSignatureMemory) throws Exception {
        return gSignatureMemoryService.addGSignature(gSignatureMemory);
    }

    public boolean updateGSignature(GSignatureMemory gSignatureMemory) throws Exception {
        return gSignatureMemoryService.updateGSignature(gSignatureMemory);
    }

    public GSignatureMemory queryGSignature(String userId, String corFlag) throws Exception {
        return gSignatureMemoryService.queryGSignature(userId, corFlag);
    }

    public FileManagerService getFileManagerService() {
        return fileManagerService;
    }

    public void setFileManagerService(FileManagerService fileManagerService) {
        this.fileManagerService = fileManagerService;
    }

    public TemplateWordService getTemplateWordService() {
        return templateWordService;
    }

    public void setTemplateWordService(TemplateWordService templateWordService) {
        this.templateWordService = templateWordService;
    }

    public EmailLogicService getEmailLogicService() {
        return emailLogicService;
    }

    public void setEmailLogicService(EmailLogicService emailLogicService) {
        this.emailLogicService = emailLogicService;
    }

    public StampService getStampService() {
        return stampService;
    }

    public void setStampService(StampService stampService) {
        this.stampService = stampService;
    }

    private SignService signService;

    public GFileService getgFileService() {
        return gFileService;
    }

    public void setgFileService(GFileService gFileService) {
        this.gFileService = gFileService;
    }

    public SignService getSignService() {
        return signService;
    }

    public void setSignService(SignService signService) {
        this.signService = signService;
    }

    public GSignatureMemoryService getgSignatureMemoryService() {
        return gSignatureMemoryService;
    }

    public void setgSignatureMemoryService(GSignatureMemoryService gSignatureMemoryService) {
        this.gSignatureMemoryService = gSignatureMemoryService;
    }
}
